package com.he.hsdyc.controller;

import com.he.hsdyc.common.OrderException;
import com.he.hsdyc.model.msg.ErrorCode;
import com.he.hsdyc.model.msg.Message;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

@RestController
@RequestMapping("exception")
public class TestExceptionController {

    @RequestMapping(value = "test",method = RequestMethod.GET)
    public Message testException(String ex) {
        Optional.ofNullable(ex).orElseThrow(() -> new OrderException(ErrorCode.ERROR_ARG));
        return new Message(ErrorCode.SUCCESS);
    }
}
